<template>
  <div class="card" :class="state ? 'openBox' : 'closeBox'">
    <div class="card_header" @click="clickBtn">
      <span>溯源信息</span>
      <i class="card_header_icon" :class="state ? 'el-icon-arrow-right' : 'el-icon-arrow-left'"></i>
    </div>
    <div class="card_info" v-show="state">
      <div class="block">
        <el-timeline>
          <el-timeline-item timestamp="2018/4/12" placement="top">
            <el-card>
              <h4>更新 Github 模板</h4>
              <p>王小虎 提交于 2018/4/12 20:46</p>
            </el-card>
          </el-timeline-item>
          <el-timeline-item timestamp="2018/4/3" placement="top">
            <el-card>
              <h4>更新 Github 模板</h4>
              <p>王小虎 提交于 2018/4/3 20:46</p>
            </el-card>
          </el-timeline-item>
          <el-timeline-item timestamp="2018/4/2" placement="top">
            <el-card>
              <h4>更新 Github 模板</h4>
              <p>王小虎 提交于 2018/4/2 20:46</p>
            </el-card>
          </el-timeline-item>
        </el-timeline>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'TraceabilityCard',
  data() {
    return {
      state: false,
    }
  },
  methods: {
    clickBtn() {
      this.state = !this.state
    }
  }
}
</script>

<style lang="scss" scoped>
.card {
  position: absolute;
  top: 200px;
  height: 400px;
  z-index: 9;
  right: 15px;
  display: flex;
  flex-direction: row;

  .card_header {
    width: 30px;
    height: 120px;
    line-height: 20px;
    background-color: #e1e1e1;
    text-align: center;
    padding: 10px 0;
    border-radius: 10px;

    &:hover {
      cursor: pointer;
    }
  }

  .card_info {
    width: 260px;
    border: 1px solid #e1e1e1;
    padding: 10px;
    background-color: #fff;
    height: 380px;
    overflow-y: auto;
  }
}

.closeBox {
  width: 30px;
}

.openBox {
  width: 300px;
}
</style>